package pe.edu.upc.dsd.agencianavierawsrs.service;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import pe.edu.upc.dsd.agencianavieraws.model.Embarque;
import pe.edu.upc.dsd.agencianavierawssoap.service.EmbarqueService;

import com.google.gson.Gson;

@Path("/desembarqueService/")
public class DesembarqueSevice {

	private Logger logger = Logger.getLogger(DesembarqueSevice.class);

	@Autowired
	private EmbarqueService embarqueService;

	@Path("/consultarDesembarque/{codigoEmbarque}")
	@GET
	@Produces("application/json")
	public String consultarDesembarque(
			@PathParam("codigoEmbarque") String codigoEmbarque) {
		logger.debug("codigoEmbarque:" + codigoEmbarque);
		String desembarque = "";
		Gson gson = new Gson();
		Embarque embarque =embarqueService.obtenerEmbarque(codigoEmbarque);
		desembarque = embarque == null ? "" : gson.toJson(embarque);
		logger.debug("desembarque:" + desembarque);
		return desembarque;
	}

}
